<template>
  <a-select show-search placeholder="选择用户" v-model:value="userVal" style="width: 250px" :options="users"
    @change="handleChange"></a-select>
</template>
<script setup>
import Users from "@/module/system/api/user.js";
const users = ref([]);
const userVal = ref("");
const emit = defineEmits(["getUser"]);
const props = defineProps({
  role: {
    type: String,
    default: "无",
  },
});
function handleChange() {
  Users.queryOne(userVal.value).then((res) => {
    res.role = props.role;
    // console.log('change', res);
    emit("getUser", res);
  });
}
function getList() {
  Users.queryList({ pageSize: 9999, pageNum: 1 }).then((res) => {
    res.content.forEach((item) => {
      item.label = item.nickName;
      item.value = item.id;
    });
    users.value = res.content;
  });
}
getList();
</script>
